/**
 * 中间件测试用例
 */
/**
 * 替换原来的dispatch
 */

// export const logger1 = (store) => {
//   let next = store.dispatch;
//   store.dispatch = function (action) {
//     console.log('进入logger1');
//     const result = next(action);
//     console.log('离开logger1');
//     return result;
//   }
// }

// export const logger2 = (store) => {
//   let next = store.dispatch;
//   store.dispatch = function (action) {
//     console.log('进入logger2');
//     const result = next(action);
//     console.log('离开logger2');
//     return result;
//   }
// }

/**
 * 不替换原来的dispatch
 * 而是返回一个新的dispatch
 */

export const logger1 = store => next => action => {
  console.log('进入logger1');
  const result = next(action);
  console.log('离开logger1');
  return result;
}

export const logger2 = store => next => action => {
  console.log('进入logger2');
  const result = next(action);
  console.log('离开logger2');
  return result;
}